package com.kly.cashmall.module.splash.adapter;

import android.app.Activity;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.PagerAdapter;

import com.kly.cashmall.R;
import com.kly.cashmall.utils.function.CommonUtils;

import java.util.List;

public class GuideWelcomeAdapter extends PagerAdapter {


    private final List<Integer> guideList;
    private final Activity context;
    private List<Integer> textContentListOne;
    private List<Integer> textContentListTwo;
    private List<Integer> textContentListThree;
    private List<Integer> titleList;

    public GuideWelcomeAdapter(Activity context, List<Integer> guideList, List<Integer> titleList, List<Integer> textContentListOne, List<Integer> textContentListTwo, List<Integer> textContentListThree) {
        this.guideList = guideList;
        this.context = context;
        this.titleList = titleList;
        this.textContentListOne = textContentListOne;
        this.textContentListTwo = textContentListTwo;
        this.textContentListThree = textContentListThree;
    }

    @Override
    public int getCount() {
        return guideList == null ? 0 : guideList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View linearLayout = LayoutInflater.from(container.getContext()).inflate(R.layout.layout_guide_item, container, false);
        ImageView itemAd = linearLayout.findViewById(R.id.item_ad);
        TextView itemtitle = linearLayout.findViewById(R.id.item_title);
        TextView itemTextOne = linearLayout.findViewById(R.id.item_text_content_one);
        TextView itemTextTwo = linearLayout.findViewById(R.id.item_text_content_two);
        TextView itemTextThree = linearLayout.findViewById(R.id.item_text_content_three);
        itemAd.setImageResource(guideList.get(position));
        itemtitle.setText(titleList.get(position));
        itemTextOne.setText(textContentListOne.get(position));
        itemTextTwo.setText(textContentListTwo.get(position));
        itemTextThree.setText(textContentListThree.get(position));
        container.addView(linearLayout);
        return linearLayout;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        View view = (View) object;
        container.removeView(view);
    }
}
